package com.guslegend.config;

import lombok.Data;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: guslegend
 * @description: redis配置类
 * @create: 2025-06-04 21:40
 **/
@Configuration
@Data
public class RedissonConfig {
    @org.springframework.beans.factory.annotation.Value("${spring.redis.host}")
    private String redisHost;
    @org.springframework.beans.factory.annotation.Value("${spring.redis.port}")
    private String redisPort;
    @Value("${spring.redis.password}")
    private String redisPwd;

    @Bean
    public RedissonClient redissonClient() {
        Config config = new Config();
        config.useSingleServer().setAddress("redis://" + redisHost + ":" + redisPort).setPassword(redisPwd);
        RedissonClient redissonClient = Redisson.create(config);
        return redissonClient;
    }
}
